//
//  Defines.h
//  SmartTalk
//
//  Created by 陈勃 on 14-12-22.
//  Copyright (c) 2014年 gameabc. All rights reserved.
//

//
//  TTDefines.h
//  ttongnew
//
//  Created by System Administrator on 8/15/14.
//  Copyright (c) 2014 SNDA. All rights reserved.
//

#if defined(DEBUG)
#define TTLog(STRLOG)	NSLog(@"%@: %@ %@", self, NSStringFromSelector(_cmd), STRLOG)
//#define TTLog(STRLOG)	if (STRLOG) { NSLog(@"%@: %@ %@", self, NSStringFromSelector(_cmd), STRLOG); } else { NSLog(@"%@: %@", self, NSStringFromSelector(_cmd));}
#define TDLog( s, ... ) NSLog(@"<%p %@::(%d)> [%@] %@", self, [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__,  NSStringFromSelector(_cmd),[NSString stringWithFormat:(s), ##__VA_ARGS__] )
#else
#if TARGET_IPHONE_SIMULATOR
// 模拟器中仍然显示日志
#define TTLog(STRLOG)	NSLog(@"%@: %@ %@", self, NSStringFromSelector(_cmd), STRLOG)
#define TDLog( s, ... ) NSLog(@"<%p %@::(%d)> [%@] %@", self, [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__,  NSStringFromSelector(_cmd),[NSString stringWithFormat:(s), ##__VA_ARGS__] )
#else
// release版本目前也增加日志吧,正式发部时再决定是否去掉
//#define TTLog(STRLOG)
#define TTLog(STRLOG)	NSLog(@"%@: %@ %@", self, NSStringFromSelector(_cmd), STRLOG)
#define TDLog( s, ... ) NSLog(@"<%p %@::(%d)> [%@] %@", self, [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__,  NSStringFromSelector(_cmd),[NSString stringWithFormat:(s), ##__VA_ARGS__] )
#endif
#endif

#define SYNTHESIZE_SINGLETON_FOR_CLASS(classname) \
\
static classname *sharedInstance = nil; \
\
+ (classname *)sharedInstance \
{ \
@synchronized(self) \
{ \
if (sharedInstance == nil) \
{ \
sharedInstance = [[self alloc] init]; \
} \
} \
\
return sharedInstance; \
} \
\
+ (id)allocWithZone:(NSZone *)zone \
{ \
@synchronized(self) \
{ \
if (sharedInstance == nil) \
{ \
sharedInstance = [super allocWithZone:zone]; \
return sharedInstance; \
} \
} \
\
return nil; \
} \
\
- (id)copyWithZone:(NSZone *)zone \
{ \
return self; \
}

#define RGB(r,g,b)  [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:1.0f]
#define RGBA(r,g,b,a)  [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]

#define KEY_RESULT_CODE @"code"
#define KEY_RESULT_MSG @"msg"
#define KEY_RESULT_OBJ @"obj"
#define KEY_RESULT_DIC @"dic"
#define KEY_RESULT_ARRAY @"array"

#define isIphone6_Plus ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO) //判断手机规格

#define network_download_queue dispatch_queue_create("com.tongtong.network.download", nil)
#define cache_file_queue dispatch_queue_create("com.tongtong.cachefile", nil)

#define LIBRARY_PATH [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0]
#define IMAGE_CACHE_PATH  [LIBRARY_PATH stringByAppendingPathComponent:@"IMAGE_CACHE/"]

